package com.zhouyu;

import com.zhouyu.service.UserService;
import com.zhouyu.service.UserServiceInterface;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author leimingchao
 * create 2025-05-15 20:55
 */
public class TestJDK {

	public static void main(String[] args) {
		UserService target = new UserService();

		UserServiceInterface userServiceInterface = (UserServiceInterface) Proxy.newProxyInstance(TestJDK.class.getClassLoader(), new Class[]{UserServiceInterface.class}, new InvocationHandler() {
			@Override
			public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
				System.out.println("before");
				method.invoke(target, args);
				return null;
			}
		});

		//userServiceInterface.test();
	}
}
